<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"
              encoding="utf-8"
              media-type="text/html"
              doctype-public="-//W3C//DTD HTML 4.01//EN"
              doctype-system="http://www.w3.org/TR/xtml4/strict.dtd" />

  <xsl:template match="/">
    <xsl:apply-templates select="content/comment" />
  </xsl:template>

  <xsl:template match="comment">
    <div>
      <div class='comment' data-table='comments' data-rec-id='{@id}'>
        <xsl:apply-templates select="autor" />
        <span class='autor'>
          <span class='ui-icon ui-icon-calendar' /><xsl:value-of select="@date-time" />
        </span>
        <xsl:if test="//auth">
          <span class='autor'>
            <span class='ui-icon ui-icon-comment' />
            <span><a href='#' class='add-comment'>Прокомментировать</a></span>
          </span>
          <xsl:if test="(//auth/@id!=autor/@id) and (@score='')">
            <span>
              <xsl:call-template name="vote">
                <xsl:with-param name="class">autor vote</xsl:with-param>
              </xsl:call-template>
            </span>
          </xsl:if>
        </xsl:if>
      </div>
      <div class='text'>
        <xsl:value-of select="content" disable-output-escaping="yes" />
      </div>
      <xsl:if test="@can-remove=1">
        <p>
          <span class='ui-icon ui-icon-trash' />&#160;<a href='#' class='del-comment'>Удалить</a>
        </p>
      </xsl:if>
      <xsl:apply-templates select="comments" />
    </div>
    <xsl:if test="@can-remove=1">
      <div class='sentenced invisible'>
        <label class='errorMessage'>Комментарий удален</label>&#160;
        <span class='ui-icon ui-icon-close' />&#160;<a href='#' class='restore-comment'>Отменить</a>
      </div>
    </xsl:if>
  </xsl:template>

  <xsl:template match="comment/autor">
    <a href='{//urls/base}/user/profile/{@login}' class='autor link aprofile'>
      <div class='ui-corner-all' style='background-image:url({@avatar}?s=24);' />
    </a>
    <a href='{//urls/base}/user/profile/{@login}' class='autor link aprofile'>
      <xsl:value-of select="." />
    </a>
  </xsl:template>

  <xsl:template name="vote">
    <xsl:param name="class">vote</xsl:param>
    <xsl:attribute name="class"><xsl:value-of select="$class" /></xsl:attribute>
    <xsl:attribute name="table"><xsl:value-of select="concat(name(), 's')" /></xsl:attribute>
    <xsl:attribute name="rec-id"><xsl:value-of select="@id" /></xsl:attribute>
    <a href='#' class='ui-icon up' title='плюсануть' data-score='plus' />
    <a href='#' class='ui-icon down' title='минусануть' data-score='minus' />
    <a href='#' class='ui-icon complaint' title='пожаловаться' data-score='complaint' />
  </xsl:template>

</xsl:stylesheet>
